home *** CD-ROM | disk | FTP | other *** search
/ Transactor / Transactor_23_1988_Transactor_Publishing.d64 / basic time (.txt) < prev    next >
Commodore BASIC  |  2023-02-26  |  2KB  |  65 lines

  1. 50000 rem subroutine to get time from
  2. 50005 rem user and convert for ti$ and
  3. 50010 rem the tod clock in cia #1.
  4. 50015 :
  5. 50020 rem by noel nyman
  6. 50025 :
  7. 50030 rem called as a subroutine
  8. 50035 :
  9. 50040 rem uses the following variables
  10. 50045 rem  ap  - am/pm flag, am=0 pm=1
  11. 50050 rem  ht  - hours, used for tod
  12. 50055 rem  mt  - minutes, used for tod
  13. 50060 rem  sc  - seconds, used for tod
  14. 50065 rem  tt  - temporary variable
  15. 50070 rem  tt% - temporary variable
  16. 50075 rem  ht$ - hours for ti$
  17. 50080 rem  mt$ - minutes for ti$
  18. 50085 rem  st$ - seconds for ti$
  19. 50090 rem  tt$ - temporary for ti$
  20. 50095 rem  ap$ - temporary variable
  21. 50099 :
  22. 50100 print "current time is " left$(ti$,2) ":" mid$(ti$,3,2) ":";
  23. 50110 print right$(ti$,2)
  24. 50120 print: print "enter new time, or  \ [146] to quit"
  25. 50130 print: print "enter new hours (0-23): ";
  26. 50140 open 9,0: input#9,ht$: close9
  27. 50150 if ht$="\" then return
  28. 50160 ht=val(ht$): if ht<0 or ht>23 goto 50130
  29. 50170 ap=0-(ht>12)
  30. 50180 :
  31. 50200 print: print "enter new minutes (0-59): ";
  32. 50210 open 9,0: input#9,mt$: close9
  33. 50220 mt=val(mt$): if mt<0 or mt>59 goto 50200
  34. 50230 if len(mt$)<2 then mt$="00"+mt$
  35. 50240 :
  36. 50300 print: print "enter new seconds (0-59): ";
  37. 50310 open 9,0: input#9,st$: close9
  38. 50320 sc=val(st$): if sc<0 or sc>59 goto 50300
  39. 50330 if len(st$)<2 then st$="00"+st$
  40. 50340 :
  41. 50400 if ap goto 50500
  42. 50410 print: if ht<12 goto 50460
  43. 50420 print "am or noon (a/n)?";
  44. 50430 get ap$: if ap$="" goto 50430
  45. 50440 if ap$<>"a" and ap$<>"[193]" and ap$<>"n" and ap$<>"[206]" goto 50430
  46. 50450 ap=0-(ap$="n")-(ap$="[206]"): goto 50500
  47. 50460 print "am or pm (a/p)?";
  48. 50470 get ap$: if ap$="" goto 50470
  49. 50480 if ap$<>"a" and ap$<>"[193]" and ap$<>"p" and ap$<>"[208]" goto 50470
  50. 50490 ap=0-(ap$="p")-(ap$="[208]")
  51. 50500 ht=ht+12*((ht=12) and (ap=0))
  52. 50510 ht=ht-12*((ht<12) and (ap=1))
  53. 50520 ht$=str$(ht): ht$="00"+right$(ht$,len(ht$)-1)
  54. 50530 tt$=right$(ht$,2)+right$(mt$,2)+right$(st$,2): ti$=tt$
  55. 50540 tt=0: if ht>12 then ht=ht-12: tt=128
  56. 50550 tt%=ht/10: tt=tt+(16*tt%)+(ht-10*tt%)
  57. 50560 poke 56335,peek(56335) and 127
  58. 50570 poke 56331,tt
  59. 50580 tt%=mt/10: tt=(16*tt%)+(mt-10*tt%)
  60. 50590 poke 56330,tt
  61. 50600 tt%=sc/10: tt=(16*tt%)+(sc-10*tt%)
  62. 50610 poke 56329,tt
  63. 50620 poke 56328,0
  64. 50630 print: goto 50100
  65.